package org.sunrise.game.game.logic.chat;

import org.sunrise.game.game.annotation.MsgHandlerClass;
import org.sunrise.game.game.annotation.MsgHandlerMethod;
import org.sunrise.game.game.gen.CallEnum;
import org.sunrise.game.game.human.HumanObject;
import org.sunrise.game.game.proto.ChatProto;
import org.sunrise.game.game.proto.TopicProto;
import org.sunrise.game.rpc.function.RpcFunction;

@MsgHandlerClass(packetType = TopicProto.TOPIC.TOPIC_TYPE_CHAT_VALUE)
public class ChatMsgHandler {
    @MsgHandlerMethod(packetId = ChatProto.FROM_CLIENT.C2S_Chat_VALUE)
    public static void chat(HumanObject humanObject, ChatProto.MC2S_Chat data) {
        if (data.getType() == 1) {
            RpcFunction.newInstance().call(CallEnum.ChatService_chat, "humanId", humanObject.getHumanId(), "type", data.getType(), "message", data.getMsg());
        } else if (data.getType() == 2) {

        }
    }

    @MsgHandlerMethod(packetId = ChatProto.FROM_CLIENT.C2S_Horn_VALUE)
    public static void horn(HumanObject humanObject) {
        humanObject.sendMsg(TopicProto.TOPIC.TOPIC_TYPE_CHAT_VALUE, ChatProto.FROM_SERVER.S2C_Horn_VALUE);
    }

    @MsgHandlerMethod(packetId = ChatProto.FROM_CLIENT.C2S_GetHistory_VALUE)
    public static void history(HumanObject humanObject) {
        RpcFunction.newInstance().call(CallEnum.ChatService_history, "humanId", humanObject.getHumanId(), "type", 1);
    }
}
